//
//  WGMTabBarViewController.m
//  IYoker_Organization
//
//  Created by chunjian Dai on 15/12/28.
//  Copyright © 2015年 wangguimin. All rights reserved.
//

#import "WGMTabBarViewController.h"
#import "UMMobClick/MobClick.h"

@interface WGMTabBarViewController ()<NetworkingHandleDelegate>


@end

@implementation WGMTabBarViewController
#pragma mark - lazeLoad -

- (NetworkManager *)manager{
    if (!_manager) {
        self.manager = [NetworkManager manager];
    }
    return _manager;
}

//- (DataBaseTool *)baseTool{
//    if (!_baseTool) {
//        self.baseTool = [DataBaseTool sharedInstance];
//    }
//    return _baseTool;
//}

/**
 *  openType
 *
 *  @return 默认是push
 */
- (OpenType)openType{
    if (!_openType) {
        self.openType = OpenTypePush;
    }
    return _openType;
}
- (TouchTableView *)tableView{
    if (!_tableView) {
        self.tableView = [[TouchTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.backgroundColor = GlobalTableViewBgColor;
        _tableView.tableFooterView = [[UIView alloc] init];
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
//        _tableView.mj_header = self.header;
//        _tableView.mj_footer = self.footer;
        
        [self.view addSubview:_tableView];
        
    }
    return _tableView;
}


//  设置导航条的左按钮
- (UIButton *)leftButton{
    if (!_leftButton) {
        self.leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _leftButton.frame = CGRectMake(0, 0, 44, 44);
        if (self.openType == OpenTypePush) {
            _leftButton.imageEdgeInsets = UIEdgeInsetsMake(0, kLeftButtonOffset, 0, 0);
            [_leftButton setImage:[UIImage imageNamed:@"btn_return"] forState:UIControlStateNormal];
        } else {
            [_leftButton setTitle:@"取消" forState:UIControlStateNormal];
            _leftButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
            _leftButton.backgroundColor = [UIColor clearColor];
            [_leftButton setTitleColor:WhiteColor forState:UIControlStateNormal];
            _leftButton.titleLabel.font = font(32);
            [_leftButton sizeToFit];
        }
        
        [_leftButton addTarget:self action:@selector(handleLeftButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _leftButton;
}
- (UIButton *)rightButton{
    if (!_rightButton) {
        self.rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _rightButton.frame = CGRectMake(0, 0, 44, 44);
        _rightButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
        _rightButton.backgroundColor = [UIColor clearColor];
        [_rightButton setTitleColor:WhiteColor forState:UIControlStateNormal];
        _rightButton.titleLabel.font = font(32);
        //  设置导航条的右按钮
        self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:_rightButton];
        [_rightButton addTarget:self action:@selector(handleRightButtonAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _rightButton;
}

- (NSMutableDictionary *)params{
    
    if (!_params) {
        self.params = [NSMutableDictionary dictionary];
    }
    return _params;
    
}
#pragma mark - 初始化方法 -
- (void)initData{
    
}
- (void)initNofotication{
    
}
- (void)initView{
    
}
- (void)initNotification{
    
}
- (void)initNavigation{

}
- (void)initNetWork{

}
#pragma mark - life -


- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [MobClick beginLogPageView:[NSString stringWithFormat:@"%@",[self class]]];
    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    appDelegate.allowRotation = NO;

    self.edgesForExtendedLayout = UIRectEdgeNone;//  是表视图从导航条下开始布局显示
    [self.navigationController.navigationBar setNavigationBarTransparentWithLineAndColor:ColorWithHexString(@"41c3ff")];
    
    
}

- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    self.view.backgroundColor = GlobalBgColor; //  设置当前视图控制器的背景图片
    
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(loginOut:)
                                                 name:kNotificationLoginOut
                                               object:nil];
//    self.navigationController.navigationBar.translucent = NO;//    Bar的模糊效果，默认为YES
    
}
- (void)loginOut:(NSNotification *)notification
{
    
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    
    [MobClick endLogPageView:[NSString stringWithFormat:@"%@",[self class]]];
    
}
- (void)dealloc{
    [self removeObserver:self];
}

#pragma mark - buttonAction -
- (void)handleLeftButtonAction:(UIButton *)sender{
    
    switch (self.openType) {
        case OpenTypePush:
            [self.navigationController popViewControllerAnimated:YES];
            break;
            
        case OpenTypePresent:
            [self dismissViewControllerAnimated:YES completion:nil];
            break;
            
        default:
            break;
    }
    
    
}
- (void)handleRightButtonAction:(UIButton *)sender{

}

#pragma mark - UITableViewDelegate,UITableViewDataSource -
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return nil;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 0;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.001f;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    if ([self.view window] == nil)// 是否是正在使用的视图
    {
        self.view = nil;// 目的是再次进入时能够重新加载调用viewDidLoad函数。
    }
    // Dispose of any resources that can be recreated.
}
#pragma mark 下拉刷新和上拉加载
- (MJRefreshGifHeader *)gifHeader{
    if (!_gifHeader) {
        self.gifHeader = [MJRefreshGifHeader headerWithRefreshingTarget:self refreshingAction:@selector(handleHeaderRefreshingAction)];
        //  设置刷新的属性
    }
    return _gifHeader;
}
- (MJRefreshNormalHeader *)header{
    if (!_header) {
        self.header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(handleHeaderRefreshingAction)];
        //  设置刷新的属性
    }
    return _header;
}

- (MJRefreshBackNormalFooter *)footer{
    if (!_footer) {
        self.footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(handleFooterRefreshingAction)];
        //  设置刷新的属性
    }
    return _footer;
}

- (void)handleHeaderRefreshingAction{

}

- (void)handleFooterRefreshingAction{
    
}

- (void)endRefresh
{
    [self.tableView.mj_header endRefreshing];
    [self.tableView.mj_footer endRefreshing];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
